
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><?php echo $title;?></title>
    <!-- 设置缩放 -->
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
    <meta name="format-detection" content="telephone=no" />
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- icon -->
    <link rel="shortcut icon" href="<?php echo ADMIN_ICO_PIC;?>" type="image/x-icon"/>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SYS_LINK;?>admin/css/content.css?v=<?php echo V_CSSJS;?>" />

    <style>

    </style>
</head>
<?php
$userLevel = getUserLevel();
$mouldCode = isset($mouldCode) ? $mouldCode : '';
$mouldInfo = isset($mouldInfo) ? $mouldInfo : array();
$sortFlag = isset($sortFlag) ? $sortFlag : '';
$tableId = isset($tableId) ? $tableId : '';
$tableIdName = $tableId == 1 ? '主表' : ($tableId == 2 ? '副表' : '子表');
$tableIdNameHtml = '<font color="#00BCD4">'.$tableIdName.'</font>';
?>
<body>
    <div class="con_box">
        <!-- 菜单 -->
        <div class="lab_box2" style="width:1100px;">
            <?php
            $classAct1 = $tableId == 1 ? array('act','<i class="lab_act2"></i>') : array('','');
            $classAct2 = $tableId == 2 ? array('act','<i class="lab_act2"></i>') : array('','');
            $classAct3 = $tableId == 3 ? array('act','<i class="lab_act2"></i>') : array('','');
            $urlListMain = SYS_URL_PATH("admin_field_index/mouldcode/$mouldCode/sortflag/$sortFlag/tableid/1");
            $urlListVice = SYS_URL_PATH("admin_field_index/mouldcode/$mouldCode/sortflag/$sortFlag/tableid/2");
            $urlListSide = SYS_URL_PATH("admin_field_index/mouldcode/$mouldCode/sortflag/$sortFlag/tableid/3");
            $urlListAdd = SYS_URL_PATH("admin_field_add/mouldcode/$mouldCode/sortflag/$sortFlag/tableid/$tableId");
            echo '<a href="'.$urlListMain.'" class="lab_base2 '.$classAct1[0].'">模型主表字段'.$classAct1[1].'</a>'.PHP_EOL;
            echo '<a href="'.$urlListVice.'" class="lab_base2 '.$classAct2[0].'">模型副表字段'.$classAct2[1].'</a>'.PHP_EOL;
            if(isset($mouldInfo['sideflag']) && $mouldInfo['sideflag'] == 1){
                echo '<a href="'.$urlListSide.'" class="lab_base2 '.$classAct3[0].'">模型子表字段'.$classAct3[1].'</a>'.PHP_EOL;
            }
            echo '<a href="javascript:;" data-url="'.$urlListAdd.'" class="lab_base2 btn_field_add">+添加'.$tableIdNameHtml.'字段</a>'.PHP_EOL;
            ?>
        </div>
        <!-- 数据 -->
        <table class="table_th_td" style="width:1100px;">
            <tr class="weight400">
                <th width="50">排序</th>
                <th width="60">ID</th>
                <th>字段名称</th>
                <th width="100">字段标识</th>
                <th width="80">字段长度</th>
                <th width="80">所属模型</th>
                <th width="80">字段类型</th>
                <th width="80">列表展示</th>
                <th width="80">字段状态</th>
                <th width="150">操作</th>
            </tr>
            <?php
            foreach($fieldList as $v){
                $id = $v['id'];
                $viewseq = $v['viewseq'];
                $mould_code = $v['mould_code'];
                $fieldname = $v['fieldname'];
                $fieldcode = $v['fieldcode'];
                $fieldlong = $v['fieldlong'];
                $fieldtype = $v['fieldtype'];
                $fieldtypetxt = $v['fieldtypetxt'];
                $statustxt = $v['statustxt'];
                $statusC = $v['status'] == 2 ? 'statusClose' : ($v['status'] == 3 ? 'statusHide' : '');
                $showflag = $v['showflag'] == 2 ? '展示' : '隐藏';
                $showflagC = $v['showflag'] == 2 ? '' : 'statusHide';
                $updateUrl = SYS_URL_PATH("admin_field_update/id/$id");
                $delUrl = SYS_URL_PATH("admin_field_del/id/$id");
                echo <<<html
            <tr>
                <td class="center"><input type="text" class="viewseq" data-id="$id" value="$viewseq"></td>
                <td class="center">$id</td>
                <td class="other_btn btn_field_up" data-url="$updateUrl">$fieldname</td>
                <td class="center">$fieldcode</td>
                <td class="center">$fieldlong</td>
                <td class="center">$mould_code</td>
                <td class="center">$fieldtypetxt</td>
                <td class="center $showflagC">$showflag</td>
                <td class="center $statusC">$statustxt</td>
                <td class="center">
                    <a href="javascript:;" data-url="$updateUrl" class="btn_base btn_line_none btn_field_up" >编辑</a>
                    <a href="javascript:;" data-url="$delUrl" class="btn_base btn_line_none btn_field_del" >删除</a>
                </td>
            </tr>
html;

            }
            ?>
            <tr class="operates_box">
                <td class="center" >
                    <button class="btn_base btn_height20 btn_line_none" id="viewseq_btn" title="提交排序"
                            data-url="<?php echo SYS_URL_PATH('admin_field_seq')?>">↓↑</button>
                </td>
                <td colspan="9"></td>
            </tr>
        </table>
    </div>
</body>
<script language="javascript">
    var cssjsv = '<?php echo V_CSSJS;?>';
    var http_url = '<?php echo SYS_HOST;?>';
    var http_link = '<?php echo SYS_LINK;?>';
    var http_fix = '<?php echo SYS_URL_FIX;?>';
</script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/jquery.min.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/skin.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/common.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript">file_load('list');</script>
<script language="javascript">
    // 加载完毕后
    window.onload = function () {

    }

    //添加/修改
    $('.btn_field_add,.btn_field_up').click(function(){
        layerIframeOpen($(this).attr('data-url'), '90%', '90%', 1);
    })

    //删除
    var flagSub = true;
    $('.btn_field_del').click(function(){
        let goutoURL = $(this).attr('data-url');
        if(!goutoURL){
            layer.msg('网络异常');
        }else{
            layer.confirm('确定删除？会删除对应的表结构', {
                btn: ['确定','取消']
            }, function(){
                if(!flagSub){
                    layer.msg('删除中……(禁止重复提交)');return false;
                }
                flagSub = false;
                $.post(goutoURL, {subFlag:'Y'}, function(data){
                    flagSub = true;
                    if(data=='Y'){
                        layer.msg('删除成功');
                        setTimeout(function(){
                            window.location.reload();
                        },2500);
                    }else{
                        layer.msg('操作失败_'+data);
                    }
                },'json').error(function(){
                    flagSub = true;
                    layer.msg('网络异常');
                });
            }, function(){ });
        }
    })

</script>
</html>